{% extends 'ArticleClientBundle::articleLayout.html.twig' %}

{% block title %}{{ article.title }}{% endblock %}

{% block body %}
    <article class="blog">
        <header>
            <div class="date"><time datetime="{{ article.createdAt|date('c') }}">{{ article.createdAt|date('l, F j, Y') }}</time></div>
            <h2>{{ article.title }}</h2>
        </header>
{#         <img src="{{ asset(['images/', article.image]|join) }}" alt="{{ article.title }} image not found" class="large" />#}
        <div>
            <p>{{ article.content }}</p>
        </div>
    </article>
    
    <section class="comments" id="comments">
        <section class="previous-comments">
            <h3>Comments</h3>
            {% include 'ArticleClientBundle:Comment:index.html.twig' with { 'comments': comments } %}
        </section>
        <h3>Add Comment</h3>
{#         {% render 'ArticleClientBundle:Comment:create' with { 'article_id': article.id } %}#}
        {{ render(controller('ArticleClientBundle:Comment:new', { 'article_id': article.id })) }}
    </section>
    
{% endblock %}


{% block javascripts %}
<script>
var CommentJavascript = {
	editComment:function(comment_id, article_id) {
		$.ajax({
	        type: "POST",
	        url: "{{ url('article_client_comment_edit') }}",
	        data: {
	        	article_id: article_id,
	        	comment_id: comment_id
	        },
	        dataType: "html",
	        success: function(response) {
		        alert(response);
	            $('#comment_form_add').replaceWith(response);
	        }
	    });
	},
}
</script>
{% endblock %}